#include <header.h>

int main(){

    char *port = "8080";
    char *ip = "192.168.106.130";

    int socket_fd = socket(AF_INET, SOCK_STREAM, 0);


    struct sockaddr_in sock;
    sock.sin_family = AF_INET;
    sock.sin_port = htons(atoi(port));
    sock.sin_addr.s_addr = inet_addr(ip);
    connect(socket_fd, (struct sockaddr *)&sock, sizeof(sock));


    char *file_name = "1.txt";
    size_t name_len = strlen(file_name);
    send(socket_fd, &name_len, sizeof(size_t), 0);
    send(socket_fd, file_name, name_len, 0);

    int file_fd = open(file_name, O_RDWR);
    char buf[4096] = {0};
    size_t  ret = read(file_fd, buf, sizeof(buf));

    send(socket_fd, &ret, sizeof(size_t), 0);
    send(socket_fd, buf, ret, 0);
    

    close(file_fd);
    close(socket_fd);
    return 0;
}

